import request from "../axios/request";

function addUserDistrictWithDistrictIds(userId, districtIds) {
    return new Promise((resolve, reject) => {
        request("post", "/UserDistrict/add?userId=" + userId, districtIds)
            .then((resp) => {
                resolve(resp);
            }, (err) => {
                reject(err);
            })
    })
}

function addUserDistrict(data) {
    return new Promise((resolve, reject) => {
        request("post", "/UserDistrict/addUserDistrict", data).then(resp => {
            resolve(resp);
        }, (err) => {
            reject(err);
        })
    })
}

function deleteUserDistrict(userId, data) {
    return new Promise((resolve, reject) => {
        request("post", "/UserDistrict/delete?userId=" + userId, data).then(resp => {
            resolve(resp);
        }, err => {
            reject(err);
        })
    })
}

function queryUserDistrict(userId) {
    return new Promise((resolve, reject) => {
        request("get", "/district/getUserExtendMsgDistrictInfo", {userId}).then(r => {
            resolve(r);
        }, e => {
            reject(e);
        })
    })
}

export {
    addUserDistrictWithDistrictIds,
    addUserDistrict,
    deleteUserDistrict,
    queryUserDistrict,
};